# coding=utf-8
import logging
from redis import StrictRedis
from datetime import timedelta


class Config(object):
    # 密钥设置
    SECRET_KEY = "jgerhgjerhgehghghgnkjtjnkljgnkl"
    DEBUG = True

    # 缓存图片时间修改设置,24 hours
    SEND_FILE_MAX_AGE_DEFAULT = 24 * 60 * 60


    # 1 数据库的配置信息
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/info12"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 设置session commit on自动提交
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True   # 当视图函数结束后,自动提交

    # 2 redis配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    # 3 配置session信息
    SESSION_TYPE = "redis"
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    SESSION_USE_SIGNER = True
    PERMANENT_SESSION_LIFETIME = timedelta(days=2)  # session保存的时间2天

    # 4 日志级别的设置
    Level = DEBUG


# 开发环境
class DevelopConfig(Config):
    Level = logging.DEBUG


# 生产环境，线上环境
class ProductConfig(Config):
    Level= logging.ERROR
    DEBUG = False


# 测试环境
class TestingConfig(Config):
    PERMANENT_SESSION_LIFETIME = timedelta(days=1)

# 设置一个容器config_dict来管理各个环境下的配置信息
config_dict ={
    "Develop": DevelopConfig,
    "Product": ProductConfig,
    "Testing": TestingConfig,
}